﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProductionOrder" @search="()=>{getTableDataProductionOrder();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanId_FormItem" prop="PlanId" :label="$t('message.autotrans._Model_ProductionOrder_Plan')">
            <el-select v-model="searchDataProductionOrder.PlanId" clearable>
               <el-option v-for="item in stateProductionOrder.AllPlans" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProductionOrder_ProductId')">
            <el-input v-model="searchDataProductionOrder.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_ProductionOrder_ProductCode')">
            <el-input v-model="searchDataProductionOrder.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_ProductionOrder_ProductName')">
            <el-input v-model="searchDataProductionOrder.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_ProductionOrder_Wo')">
            <el-input v-model="searchDataProductionOrder.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanQty_FormItem" prop="PlanQty" :label="$t('message.autotrans._Model_ProductionOrder_PlanQty')">
            <el-input v-model="searchDataProductionOrder.PlanQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OnlineQty_FormItem" prop="OnlineQty" :label="$t('message.autotrans._Model_ProductionOrder_OnlineQty')">
            <el-input v-model="searchDataProductionOrder.OnlineQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CompletedQty_FormItem" prop="CompletedQty" :label="$t('message.autotrans._Model_ProductionOrder_CompletedQty')">
            <el-input v-model="searchDataProductionOrder.CompletedQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="QualifiedQty_FormItem" prop="QualifiedQty" :label="$t('message.autotrans._Model_ProductionOrder_QualifiedQty')">
            <el-input v-model="searchDataProductionOrder.QualifiedQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UnqualifiedQty_FormItem" prop="UnqualifiedQty" :label="$t('message.autotrans._Model_ProductionOrder_UnqualifiedQty')">
            <el-input v-model="searchDataProductionOrder.UnqualifiedQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScrapQty_FormItem" prop="ScrapQty" :label="$t('message.autotrans._Model_ProductionOrder_ScrapQty')">
            <el-input v-model="searchDataProductionOrder.ScrapQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanStartTime_FormItem" prop="PlanStartTime" :label="$t('message.autotrans._Model_ProductionOrder_PlanStartTime')">
            <el-date-picker v-model="searchDataProductionOrder.PlanStartTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanEndTime_FormItem" prop="PlanEndTime" :label="$t('message.autotrans._Model_ProductionOrder_PlanEndTime')">
            <el-date-picker v-model="searchDataProductionOrder.PlanEndTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ActualStartTime_FormItem" prop="ActualStartTime" :label="$t('message.autotrans._Model_ProductionOrder_ActualStartTime')">
            <el-date-picker v-model="searchDataProductionOrder.ActualStartTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ActualEndTime_FormItem" prop="ActualEndTime" :label="$t('message.autotrans._Model_ProductionOrder_ActualEndTime')">
            <el-date-picker v-model="searchDataProductionOrder.ActualEndTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderStatus_FormItem" prop="OrderStatus" :label="$t('message.autotrans._Model_ProductionOrder_OrderStatus')">
            <el-select v-model="searchDataProductionOrder.OrderStatus" clearable>
               <el-option key="Created" value="Created" :label="$t('message.autotrans._Enum_WoStatusEnum_Created')"></el-option>
               <el-option key="Scheduled" value="Scheduled" :label="$t('message.autotrans._Enum_WoStatusEnum_Scheduled')"></el-option>
               <el-option key="Issued" value="Issued" :label="$t('message.autotrans._Enum_WoStatusEnum_Issued')"></el-option>
               <el-option key="Executing" value="Executing" :label="$t('message.autotrans._Enum_WoStatusEnum_Executing')"></el-option>
               <el-option key="Completed" value="Completed" :label="$t('message.autotrans._Enum_WoStatusEnum_Completed')"></el-option>
               <el-option key="Paused" value="Paused" :label="$t('message.autotrans._Enum_WoStatusEnum_Paused')"></el-option>
               <el-option key="Freezed" value="Freezed" :label="$t('message.autotrans._Enum_WoStatusEnum_Freezed')"></el-option>
               <el-option key="Canceled" value="Canceled" :label="$t('message.autotrans._Enum_WoStatusEnum_Canceled')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderSource_FormItem" prop="OrderSource" :label="$t('message.autotrans._Model_ProductionOrder_OrderSource')">
            <el-select v-model="searchDataProductionOrder.OrderSource" clearable>
               <el-option key="Local" value="Local" :label="$t('message.autotrans._Enum_WoSourceEnum_Local')"></el-option>
               <el-option key="Erp" value="Erp" :label="$t('message.autotrans._Enum_WoSourceEnum_Erp')"></el-option>
               <el-option key="MOM" value="MOM" :label="$t('message.autotrans._Enum_WoSourceEnum_MOM')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sort_FormItem" prop="Sort" :label="$t('message.autotrans._Model_ProductionOrder_Sort')">
            <el-input v-model="searchDataProductionOrder.Sort" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProductionOrder_CreateTime')">
            <el-date-picker v-model="searchDataProductionOrder.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProductionOrder_UpdateTime')">
            <el-date-picker v-model="searchDataProductionOrder.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProductionOrder_CreateBy')">
            <el-input v-model="searchDataProductionOrder.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProductionOrder_UpdateBy')">
            <el-input v-model="searchDataProductionOrder.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/ProductionOrderExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProductionOrder" v-bind="tableDataProductionOrder">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/PlanningManagement/ProductionOrder/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePlanningManagementProductionOrderIndex;true;Digitalmes.PlanningManagement.Controllers;ProductionOrder">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productionorderApi } from '/@/api/planningmanagement/productionorder';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProductionOrder = reactive({
    
    AllPlans: [] as any[],
});

const searchDataProductionOrder = ref({
        PlanId: null,
        ProductId: null,
        ProductCode: '',
        ProductName: '',
        Wo: '',
        PlanQty: null,
        OnlineQty: null,
        CompletedQty: null,
        QualifiedQty: null,
        UnqualifiedQty: null,
        ScrapQty: null,
        PlanStartTime: undefined,
        PlanEndTime: undefined,
        ActualStartTime: undefined,
        ActualEndTime: undefined,
        OrderStatus: undefined,
        OrderSource: undefined,
        Sort: null,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProductionOrder = ref();
const tableDataProductionOrder = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page关联计划'),key: 'ProductionOrder_Plan',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'ProductionOrder_ProductId',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ProductionOrder_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ProductionOrder_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'ProductionOrder_Wo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划数量'),key: 'ProductionOrder_PlanQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上线数量'),key: 'ProductionOrder_OnlineQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page完工数量'),key: 'ProductionOrder_CompletedQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page合格数量'),key: 'ProductionOrder_QualifiedQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page不合格数量'),key: 'ProductionOrder_UnqualifiedQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page报废数量'),key: 'ProductionOrder_ScrapQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划开始时间'),key: 'ProductionOrder_PlanStartTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划结束时间'),key: 'ProductionOrder_PlanEndTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page实际开始时间'),key: 'ProductionOrder_ActualStartTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page实际完工时间'),key: 'ProductionOrder_ActualEndTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page订单状态'),key: 'ProductionOrder_OrderStatus',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page订单来源'),key: 'ProductionOrder_OrderSource',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page排序'),key: 'ProductionOrder_Sort',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProductionOrder_CreateTime',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProductionOrder_UpdateTime',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProductionOrder_CreateBy',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProductionOrder_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProductionOrder = () => {
    tableRefProductionOrder.value.doSearch(productionorderApi().search, searchDataProductionOrder.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProductionOrder)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProductionOrder)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProductionOrder)
};

// 删除
const onDelete = (row: any) => {
    productionorderApi().delete([row.ID]).then(() => { getTableDataProductionOrder()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProductionOrder.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      productionorderApi().delete(selectedids).then(() => { getTableDataProductionOrder()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProductionOrder.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProductionOrder)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProductionOrder)
};

const onExport = () => {
	const selected = tableRefProductionOrder.value.getSelectedRows();
	if (selected.length > 0) {
		productionorderApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		productionorderApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/PlanningManagement/ProductionOrder/GetProductionPlannings',[],false).then(x=>{stateProductionOrder.AllPlans = x});
        getTableDataProductionOrder();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

